package com.usbconnecter;

import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbDeviceConnection;
import android.util.Log;

import com.usbconnecter.eos.EosInitiator;
import com.usbconnecter.nikon.NikonInitiator;

/**
 * Created by Administrator on 2016-12-25.
 */

public class InitiatorFactory {
    private static final String TAG = "InitiatorFactory";
    public static BaselineInitiator getInitiator(UsbDevice device, UsbDeviceConnection usbDeviceConnection) throws PTPException {
        BaselineInitiator bi = new BaselineInitiator(device, usbDeviceConnection);
        // Select appropriate deviceInitiator, VIDs see http://www.linux-usb.org/usb.ids
        if (bi.device.getVendorId() == EosInitiator.CANON_VID) {
            Log.d(TAG, "Device is CANON, open EOSInitiator");
            bi = new EosInitiator(bi);
        } else if (device.getVendorId() == NikonInitiator.NIKON_VID) {
            Log.d(TAG, "Device is Nikon, open NikonInitiator");
            bi = new NikonInitiator(bi);
        }
        return bi;
    }
}
